<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
<h:head>
        <title>Patron Management</title>
        <h:outputStylesheet library="css" name="OnlineLibrary-style.css"/>
    </h:head>
    <body>
           <div  class="container">
       <div class="header">
           <h3 id="main_logo">Online Library</h3>
           <h:panelGroup rendered="#{loginManagerBean.isNotLoggedIn()}">
                 <h:form>
                          <h:outputLabel for="username" value="Username"/> <h:inputText id="username" value="#{loginManagerBean.username}" size="25" /><h:outputLabel for="password" value="password"/> <h:inputSecret value="#{loginManagerBean.password}" size="25"/>
             <h:commandButton value="Login" action="#{loginManagerBean.login()}"/>
             
                
         </h:form>   
         </h:panelGroup>
            <h:panelGroup rendered="#{loginManagerBean.isLoggedIn()}">
                <h:outputText value="Hello, #{loginManagerBean.username}"/>
            </h:panelGroup>
      
    </div>
        
 
         
         <div class="sidebarleft">
             

            <ul class="nav">
            <li><a href="http://localhost:8080/OnlineLibrary/">Home</a></li>
            <li><a href="http://localhost:8080/OnlineLibrary/search.xhtml">Search Catalog</a></li>
            <li><a href="http://localhost:8080/OnlineLibrary/patronsearch.xhtml">Patron Management</a></li>
            <li><h:link outcome="/admin/AddItems.xhtml" rendered="#{loginManagerBean.isAdmin()}">Add New Items</h:link></li>
            <li><h:link outcome="/admin/signup.xhtml" rendered="#{loginManagerBean.isAdmin()}">Add New Member</h:link></li>
            <li><h:link outcome="/admin/periodManagement.xhtml" rendered="#{loginManagerBean.isAdmin()}">Item Period Management</h:link></li>
            <li><h:link outcome="/admin/logs.xhtml" rendered="#{loginManagerBean.isAdmin()}">Activity Log</h:link></li>
            <li><h:link outcome="/browse_catalog.xhtml" rendered="#{loginManagerBean.isLoggedIn()}">Browse Catalog</h:link></li>
            <li><h:form><h:commandLink value="Logout" action="#{loginManagerBean.logout()}" rendered="#{not empty request.remoteUser}" /></h:form></li>
            </ul>
       
        </div><br/>
 
        <div class="content">
            <h3>Find a Patron and View Reports</h3>
            <h4>Please Select A Search Criteria</h4>
            <h:form>
                <h:selectOneListbox value="#{patronManagerBean.searchAction}">
                    <f:selectItem itemLabel="Last Name" itemValue="LastName"/>
                    <f:selectItem itemLabel="First Name" itemValue="FirstName"/>
                    <f:selectItem itemLabel="ID" itemValue="ID"/>
                </h:selectOneListbox>
                <h:commandButton value="Choose" action="#{patronManagerBean.searchChoice()}"/>
            </h:form>
            <br/>
            
            <!--Begin search by ID!-->
            <h:panelGroup rendered="#{patronManagerBean.searchID}">
       <p> Search By ID</p>
        <h:form>
            <h:inputText id="searchID" value="#{patronManagerBean.id}" required="true"  />
            <h:commandButton value="Search" 
                             action="#{patronManagerBean.patronIDSearch()}"/>
         </h:form> 
       
       <!-- Begin search by first name !-->
            </h:panelGroup>
            <h:panelGroup rendered="#{patronManagerBean.searchFirstName}">
                <p>Search By First Name</p>
                <h:form>
                    <h:inputText id="searchFirstName" value="#{patronManagerBean.fName}" required="true"  />
            <h:commandButton value="Search" 
                             action="#{patronManagerBean.patronFirstNameSearch()}"/>
            </h:form>
            </h:panelGroup>
        <!--Begin search by last name!-->
         <h:panelGroup rendered="#{patronManagerBean.searchLastName}">
             <p>Search By Last Name</p>
             <h:form>
                <h:inputText id="searchLastName" value="#{patronManagerBean.lName}" required="true"  />
            <h:commandButton value="Search" 
                             action="#{patronManagerBean.patronLastNameSearch()}"/>
            </h:form>
            </h:panelGroup>
        
      
       <h:panelGroup rendered="#{patronManagerBean.viewReport}">
       <h:dataTable value="#{patronManagerBean.patronList}" var="patron">
           <h:column>
               <f:facet name="header">
                   <h:outputText value="ID"/>
               </f:facet>
               <h:outputText value="#{patron.id}"/>
           </h:column>
               
           <h:column>
               <f:facet name="header">
                   <h:outputText value="FirstName"/>
                       
               </f:facet>
               <h:outputText value="#{patron.fName}"/>
           </h:column>
           <h:column>
               <f:facet name="header">
                   <h:outputText value="LastName"/>
               </f:facet>
               <h:outputText value="#{patron.lName}"/>
           </h:column>
           <h:column>
               <f:facet name="header">
                   <h:outputText value="Address"/>
               </f:facet>
               <h:outputText value="#{patron.address}"/>
           </h:column>
           <h:column>
               <f:facet name="header">
                   <h:outputText value="City"/>
               </f:facet>
               <h:outputText value="#{patron.city}"/>
               
           </h:column>
           <h:column>
               <f:facet name="header">
                   <h:outputText value ="State"/>
               </f:facet>
               <h:outputText value="#{patron.stateName}"/>
           </h:column>
           <h:column>
               <f:facet name="header">
                   <h:outputText value ="Zip Code"/>
               </f:facet>
               <h:outputText value =" #{patron.zip}"/>
           </h:column>
           <h:column>
               <f:facet name="header">
                   <h:outputText value="Action"/>
               </f:facet>
               <h:form>
                   
                   <h:commandButton value="View Report" action="#{patronManagerBean.getPatronActivityReport(patron.id)}"/>
               </h:form>
       </h:column>
       </h:dataTable> 
       </h:panelGroup>
       
       
       
       <h:panelGroup rendered="#{patronManagerBean.viewReport}">
           <h:dataTable value="#{patronManagerBean.patronActivities}" var="patronActivities">
               <h:column>
                   <f:facet name="header">
                       <h:outputText value ="Description"/>
                   </f:facet>
                   <h:outputText value="#{patronActivities.content}"/>
               </h:column>
           
           </h:dataTable>
       
       
       </h:panelGroup>
        </div>
       </div>
</body>
</html>
